# Contributor: Johannes Heimansberg <git@jhe.dedyn.io>
# Maintainer: Johannes Heimansberg <git@jhe.dedyn.io>
pkgname=getdns
pkgver=1.7.3
pkgrel=0
pkgdesc="Modern asynchronous DNS API"
url="https://getdnsapi.net"
arch="all"
license="BSD-3-Clause"
subpackages="$pkgname-dev $pkgname-libs $pkgname-doc"
makedepends="cmake
	libidn2-dev
	openssl-dev
	samurai
	unbound-dev
	yaml-dev
"
checkdepends="check-dev"
source="$pkgname-$pkgver.tar.gz::https://getdnsapi.net/dist/getdns-$pkgver.tar.gz"
options="!check" # The DNS lookups executed in the tests time out due to lack of connectivity

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_LIBEVENT2=OFF \
		-DBUILD_LIBUV=OFF \
		-DBUILD_LIBEV=OFF \
		-DBUILD_STUBBY=OFF \
		-DENABLE_UNBOUND_EVENT_API=OFF \
		-DENABLE_STATIC=OFF \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
d5725a24378b6fe0018daefdaba5565d2d4d51109ef66609fc34270a0a69accb95f5f895d0cdfc5caca51d2ec586db126f367439f05aed12507395af26739e2f  getdns-1.7.3.tar.gz
"
